Skip to content

JOB-114319 Fix zero value option bug#1

Open
graham-jobber wants to merge 2 commits into
masterfrom
JOB-114319/FixZeroValueOptionBug
Open

JOB-114319 Fix zero value option bug#1
graham-jobber wants to merge 2 commits into
masterfrom
JOB-114319/FixZeroValueOptionBug

Conversation

@graham-jobber
Copy link
Copy Markdown
Collaborator

@graham-jobber graham-jobber commented Mar 10, 2025

When switching from an option with value 0 to another option, a Javascript error is thrown:
image

The error occurs in freqInit() when the current_rule.hash is 0.
image

const rule_type = this.current_rule.hash && this.current_rule.hash.rule_type

// in this case is equivalent to:
const rule_type = 0 && undefined

// zero is "falsy" and Javascript returns the first "falsy" value that it finds so:
const rule_type = 0

The following line:

if (this.current_rule.hash != null && rule_type != null)

// becomes:
if (0 != null && 0 != null)

Which is true. To fix this, I've updated it to check that rule_type is "truthy".

if (rule_type)

@alan-jobber
Copy link
Copy Markdown

@azamb
Copy link
Copy Markdown

azamb commented Oct 9, 2025

@graham-jobber can we merge this or close this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants